﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Ken_WPF_UI.View
{
    /// <summary>
    /// StatusBarWindow.xaml 的交互逻辑
    /// </summary>
    public partial class StatusBarWindow : Window
    {
        public StatusBarWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            curTimeTxt1.Text = nowTime;
            curTimeTxt2.Text = nowTime;

            Timer timer = new Timer();
            timer.Interval = 1000;
            timer.Elapsed += Time_ElapsedEventHandler;
            timer.Start();
        }

        public void Time_ElapsedEventHandler(object sender, ElapsedEventArgs e)
        {
            this.Dispatcher.Invoke(() =>
            {
                string nowTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                curTimeTxt1.Text = nowTime;
                curTimeTxt2.Text = nowTime;
            });
        }
    }
}
